/*
* 获取百度云授权
* */
const request = require('axios');

/*
* http://openapi.baidu.com/oauth/2.0/authorize?response_type=code&client_id=kbkcBluGv7xoykbsLkS2Mlk4&redirect_uri=oob&scope=basic netdisk&display=page
* */

const tokenObj = {
  refresh_token: '122.45f77583e0b267ba427f9d994cb611ad.YHY5JfQoYcb3myHbblrdcb0-ljVO78vlXnZG7HY.Hb-Xfw',
  access_token: '121.d389c8fa826d586cbf137d5001d4f767.Y5Jr09a-aFukd489mTfDVzgfvTOhK9it3-TNq8S.dQaT7A'
};

/*
* 获取百度云的token
* */

function getToken() {
  return new Promise(s => {
    request.get('https://openapi.baidu.com/oauth/2.0/token?grant_type=authorization_code&code=a8a8504ae6843125b2f5f3ff8a3b6765&client_id=kbkcBluGv7xoykbsLkS2Mlk4&client_secret=GZpg2fNBgsAO7PW8UzdAKnQSpwHokk4P&redirect_uri=oob')
      .then(res => {
        console.log(res);
      }).catch(e => {
      console.log(e);
    });
  });
}

function updateToken() {
  return new Promise(s => {
    request.get('https://openapi.baidu.com/oauth/2.0/token?grant_type=refresh_token&refresh_token=122.e5522885eb530c971f0e50c981d51e92.Y3fNp0W2n2tNOPLjaYg9AMYhF-hcwJeSBJBbq1Q.uCQFQA&client_id=kbkcBluGv7xoykbsLkS2Mlk4&client_secret=GZpg2fNBgsAO7PW8UzdAKnQSpwHokk4P&scope=basic')
      .then(res => {
        console.log(res);
      }).catch(e => {
      console.log(e);
    });
  });
}
// updateToken();
module.exports = tokenObj;
